package com.tianji.aigc.agent;

import com.tianji.aigc.config.SystemPromptConfig;
import com.tianji.aigc.constants.Constants;
import com.tianji.aigc.enums.AgentTypeEnum;
import com.tianji.aigc.tools.CourseTool;
import lombok.RequiredArgsConstructor;
import org.springframework.ai.chat.client.advisor.QuestionAnswerAdvisor;
import org.springframework.ai.chat.client.advisor.api.Advisor;
import org.springframework.ai.vectorstore.SearchRequest;
import org.springframework.ai.vectorstore.VectorStore;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * @author Administrator
 * @version 1.0
 * @description: TODO
 * @date 2025/7/24 12:27
 */
@Component
@RequiredArgsConstructor
public class RecommendAgent extends AbstractAgent{
    private final SystemPromptConfig systemPromptConfig;
    private final CourseTool courseTool;
    private final VectorStore vectorStore;

    /**
     * 1、大模型提示词
     *
     * @return 提示词
     */
    @Override
    public String systemMessage() {
        return systemPromptConfig.getRecommendAgentSystemMessage().get();
    }

    /**
     * 8、大模型外部工具
     *
     * @return 工具数组
     */
    @Override
    public Object[] tools() {
        return new Object[]{courseTool};
    }

    /**
     * 9、大模型外部工具参数
     *
     * @return 工具参数
     */
    @Override
    public Map<String, Object> toolContext(String requestId) {
        return Map.of(Constants.REQUEST_ID, requestId);
    }

    /**
     * 6、大模型增强器
     *
     * @return 动态参数Map
     */
    @Override
    public List<Advisor> advisors() {
        return List.of(new QuestionAnswerAdvisor(vectorStore, SearchRequest.builder().query("").topK(999).build()));
    }

    /**
     * 10、获取智能体类型
     *
     * @return
     */
    @Override
    public AgentTypeEnum getAgentType() {
        return AgentTypeEnum.RECOMMEND;
    }
}
